function EPSPbootstrapping(varargin)
% plot mean EPSP amplitude of all pairs and its confidence interval. The
% confidence interval is found by bootstrapping.
% cf. cellDistributionAnalysis.m and finalsummary.m
% run this fcn after using finalsummary.m
% written by Taro Kiritani, tarokiritani2008@u.northwestern.edu

% the denominator has to be specified manually. This should be modified,
% but ok for now.
unconnectedNum = [345 91 130];

for numConnection = 1:nargin
    clear epsp
    Connection = varargin{1,nargin};
    for k = 1:length(Connection)
        epsp(k) = Connection(1,k).firstEPSPamp;
    end

    epsp = [epsp,zeros(1,unconnectedNum(numConnection))];
    meanepsp(numConnection) = mean(epsp);
    % bootstrapping for mean.
    errorepsp(:,numConnection) = bootci(10000, {@mean, epsp}, 'type','per');
end
figure;

colorMat = [0 0 1;0 1 0;1 0 0];

ezbarweb(meanepsp, meanepsp - errorepsp(1,:), meanepsp - errorepsp(2,:),colorMat)
% bar([1 2 3],meanepsp,'facecolor',[.5 .5 .5])
% hold on;
% errorbar([1 2 3],meanepsp,meanepsp - errorepsp(1),meanepsp - errorepsp(2),...
%     'LineStyle','none','color','k');
ylabel('EPSP Amplitude\newlinebetween Two Cells (mV)','interpreter','tex')
xticklabel_rotate([1 2 3],0,{'CSp > CSp','CSt > CSp','CSt > CSt'},'HorizontalAlignment','center')
